import { Component, EventEmitter } from "@angular/core";
import { TableHeader } from "../../f10-shared/interface-shared";

@Component({
  selector: "classify-table",
  templateUrl: "classify-table.component.html",
  styleUrls: ['classify-table.component.less'],
  inputs: ['data', 'header', 'clickedKey'],
  outputs: ['togglePolarChart']
})
export class ClassifyTableComponent {
  ClassificationDict: string[] = ['按行业', '按产品', '按地区', '按业务'];
  togglePolarChart = new EventEmitter();
  clickedKey: string;
  constructor () {}

  toggleChart (event) {
    this.togglePolarChart.emit(event)
  }

  trackByHeader (index: number, header: TableHeader) {
    return header.key
  }

  trackByGroup (index: number, group: any) {
    return group.type
  }

  trackByBusiness (index: number, business: any) {
    return business.project
  }

  tdActived (tabContect) {
    return tabContect === this.clickedKey
  }
}